package com.dabai.qrtools.data;

import android.content.Context;
import android.graphics.Color;

import androidx.annotation.NonNull;

import com.dabai.qrtools.R;
import com.dabai.qrtools.bean.SmallProgramInfo;
import com.dabai.qrtools.qrcode.QRCodeDialog;
import com.dabai.qrtools.ui.BarCodeActivity;
import com.dabai.qrtools.ui.WatermarkActivity;
import com.dabai.qrtools.utils.ShareUtils;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;

import java.util.ArrayList;

/**
 * Description : Other
 *
 * @author BAI
 */
public class InitSmallProgram {

    /**
     * init小程序
     *
     * @param smallProgramInflows 小程序流入
     */
    public static void initSmallProgram(@NonNull ArrayList<SmallProgramInfo> smallProgramInflows) {


        smallProgramInflows.add(new SmallProgramInfo("条形码生成"
                , "生成数字条形码"
                , R.drawable.ic_round_qr_code_24
                , BarCodeActivity.class));

        smallProgramInflows.add(new SmallProgramInfo("旧版扫描器"
                , "可以扫描条形码的扫描器"
                , R.drawable.ic_round_qr_code_scanner_24
                , null));

        smallProgramInflows.add(new SmallProgramInfo("多彩二维码"
                , "生成更多样式的二维码和GIF二维码"
                , R.drawable.ic_round_qr_code_24
                , null));

        smallProgramInflows.add(new SmallProgramInfo("二维码水印"
                , "将二维码水印添加到图片"
                , R.drawable.ic_round_qr_code_24
                , WatermarkActivity.class));


        smallProgramInflows.add(new SmallProgramInfo("分享文本生成"
                , "下载\"分享文本到生成二维码\"工具"
                , R.drawable.ic_round_link_24
                , null));

        smallProgramInflows.add(new SmallProgramInfo("王者荣耀房间二维码"
                , "下载\"王者荣耀房间链接生成二维码\"工具"
                , R.drawable.ic_round_link_24
                , null));

        smallProgramInflows.add(new SmallProgramInfo("微信扫一扫"
                , "添加\"微信扫一扫\"到桌面"
                , R.drawable.ic_round_touch_app_24
                , null));

        smallProgramInflows.add(new SmallProgramInfo("查删二维码"
                , "列出图库中的二维码图片"
                , R.drawable.ic_outline_scanner_24
                , null));

    }


    /**
     * 分享应用
     *
     * @param context 上下文
     */
    public static void shareApp(Context context) {
        new MaterialAlertDialogBuilder(context)
                .setTitle("分享软件")
                .setItems(new String[]{"二维码分享", "链接分享"}, (dialog, which) -> {
                    if (which == 0) {
                        QRCodeDialog.showSimpleQrCodeDialog(context, "扫码下载", "https://www.coolapk.com/apk/" + context.getPackageName())
                                .getWindow().setWindowAnimations(R.style.DBAnim_Transitions_IOS);
                    }
                    if (which == 1) {
                        ShareUtils.shareFromCoolApk(context, R.string.app_name);
                    }
                }).show().getWindow().setWindowAnimations(R.style.DBAnim_Transitions_IOS);

    }
}
